<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>catch 方法 </title>
</head>
<body>
    <script>
        // console.dir(Promise);
        //
        let p = new Promise((resolve, reject) => {
            resolve('OK');
            // reject('Error');
        });

        //catch 作用: 指定 promise 对象『失败』的回调
        // p.catch(r => {
        //     console.log(r);
        // });

        //异常穿透
        p.then(v => {
            console.log(v);
            throw 'error';
        }).then(v => {
            console.log(v);
        }).then(v=>{
            console.log(v);
        }).catch(r => {
            console.warn(r);
        })

    </script>
</body>
</html>